package cn.hello1023.springbootlabs.config;

import cn.hello1023.springbootlabs.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class LoginConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 对所有访问路径，都通过LoginInterceptor拦截器进行拦截,拦截路径为“/**”，表示拦截所有请求，包括对静态资源的请求。
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/css/**", "/images/**", "/js/**", "/fonts/**");
        //放行静态资源
    }
}
